package model.user;

import net.passClass.PassData;
import util.MD5;

import java.util.Objects;

public class User {
    private String userName;
    private String password;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public User(String name, String password) {
        this.userName = name;
        this.password = password;
    }

    public User() {
    }

    public static PassData login(User user){
        if(Admin.getInstance().getUserName().equals(user.getUserName())){
            if(Objects.equals(MD5.md5Encryption(Admin.getInstance().getPassword()),
                    user.getPassword())){
                return new PassData(true,null,"管理员登陆成功");
            }
            return new PassData(false,null,"管理员登陆失败");
        }
        return StaffDB.getInstance().login(user);
    }
}
